import request from '@/utils/request'

// 查询附件管理列表
export function listAttachment(query) {
  return request({
    url: '/pg/attachment/list',
    method: 'get',
    params: query
  })
}

// 查询附件管理详细
export function getAttachment(attachId) {
  return request({
    url: '/pg/attachment/' + attachId,
    method: 'get'
  })
}

// 新增附件管理
export function addAttachment(data) {
  return request({
    url: '/pg/attachment',
    method: 'post',
    data: data
  })
}

// 修改附件管理
export function updateAttachment(data) {
  return request({
    url: '/pg/attachment',
    method: 'put',
    data: data
  })
}

// 删除附件管理
export function delAttachment(attachIds) {
  return request({
    url: `/pg/attachment/remove/${attachIds}`,
    method: 'delete'
  })
}

// 查询指标下拉树结构
export function indicatorTreeSelect() {
  return request({
    url: '/pg/attachment/indicatorTree',
    method: 'get'
  })
}

export function uploadFile(data) {
  return request({
    url: '/pg/attachment/upload',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

// 文件预览接口
export function previewFile(data) {
  return request({
    url: '/pg/attachment/file/preview',
    method: 'get',
    params:data,
    responseType: 'blob' // 必须指定
  })
}
// 根据教师 ID 获取附件信息
export function getAttachmentInfoByTeacherId(teacherId) {
  return request({
    url: '/pg/attachment/getInfoByTeacherId',
    method: 'get',
    params: { teacherId }
  })
}
